local ffi = require("ffi");
assert(#arg>0,"no input file");
local file = io.open(arg[1],"rb");
assert(file,"open file error");

local d = file:read('*a');
local data = ffi.new('uint8_t[?]',2*1024*1024*16);
ffi.copy(data,d,#d);
ffi.cdef[[

typedef	unsigned char			u8;		/**< Unsigned 8 bit value	*/
typedef	unsigned short int		u16;	/**< Unsigned 16 bit value	*/
typedef	unsigned int			u32;	/**< Unsigned 32 bit value	*/
typedef	signed char				s8;		/**< Signed 8 bit value	*/
typedef	signed short int		s16;	/**< Signed 16 bit value	*/
typedef	signed int				s32;	/**< Signed 32 bit value	*/
typedef struct{
    u8      name[12];
    u32     anime_type_addr;
    u32     event_addr;     //0x10
    u32     coord_addr;     //右边坐标 0x14
    u32     coord2_addr;    //左边坐标 0x18
    u32     pal_addr;       //调色板地址 0x1c
}data_t;
]];

local fa = ffi.cast("data_t*",data+0xC00008);
local fa_end = ffi.cast("data_t*",data+0xC01930);
local num = 0;
while(fa<fa_end)do
    print(string.format('[%d] = {"%s",0x%08X,0x%08X,0x%08X,0x%08X,0x%08X},',
        num,
        ffi.string(fa.name),
        fa.anime_type_addr,
        fa.event_addr,
        fa.coord_addr,
        fa.coord2_addr,
        fa.pal_addr
    ));
    num = num + 1;
    fa = fa + 1;
end

